<template>
  <el-dialog
    title="异动审核"
    :model-value="modelValue"
    @close="closed"
    width="600px" ref="recordRef" 
  >
    <el-form label-width="100px" :model="form">
      <el-form-item label="是否通过" prop="isPass">
        <el-select v-model="form.isPass" placeholder="请选择" clearable style="width: 100%;">
          <el-option
            v-for="dict in dl_ispass"
            :key="dict.label"
            :label="dict.label"
            :value="dict.label"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="选择审批人" v-if="form.isPass=='是'">
        <el-button type="primary" @click="selectReviewClick">选择审批人</el-button>
      </el-form-item>
      <el-form-item label="审批人" prop="handleUserName" v-if="form.isPass=='是'">
        <el-input :disabled="true"  v-model="form.handleUserName"></el-input>
      </el-form-item>
      <el-form-item label="审核内容" prop="reviewContent">
        <el-input v-model="form.reviewContent" placeholder="" type="textarea" />
      </el-form-item>
    </el-form>

    <template #footer>
      <span class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="closed">关闭</el-button>
      </span>
    </template>
    <div>
        <selectApproveDialog v-model="selectReviewVisible" @select="handleSelectReview"></selectApproveDialog>
    </div>
  </el-dialog>
</template>
  
<script setup>

import selectApproveDialog from "@/views/workOrder/waitingToDo/dialog/selectApproveDialog.vue";

const { proxy } = getCurrentInstance();
const { dl_ispass } = proxy.useDict("dl_ispass");

const props = defineProps({
  modelValue: {
    type: Boolean,
    required: true,
  },
});
const emits = defineEmits(["update:modelValue", "refresh"]);

const data = reactive({
  form: {},
});

const { form } = toRefs(data);

/**
 * 关闭
 */
const closed = () => {
  emits("update:modelValue", false);
};

const submitForm = () => {
  // proxy.$refs["recordRef"].validate((valid) => {
  //   if (valid) {
  //     emits("review", form.value);
  //     closed();
  //   }
  // });
   emits("review", form.value);
      closed();
};


const selectReviewVisible = ref(false)
const selectReviewClick = () => {
  selectReviewVisible.value = true;
}

const handleSelectReview = (row) => {
  form.value.handleUser = row.userId;
  form.value.handleUserName = row.nickName
}

</script>
  
  <style lang="scss" scoped>
.center {
  text-align: center;
  .title {
    margin-bottom: 12px;
  }
}
</style>